package com.jingbo.servlet;

import com.jingbo.DAO.Record.pecordimpl;
import com.jingbo.entity.Profile;
import com.jingbo.service.record.recordimpl;
import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;

/**
 * @author jiangjingbo
 * @version V1.0
 * @Project java2203
 * @Package com.jingbo.servlet
 * @Description:
 * @Date 2022/5/27 14:43
 */

@WebServlet("/Addrecord")
public class Addrecord extends  BeanServlet {
    public String addrecord(HttpServletRequest request , HttpServletResponse response) throws InvocationTargetException, IllegalAccessException {
//
//        String[] array = {"1" , "aa"};
//        array[3];
        Map<String, String[]> map = request.getParameterMap();
        Profile profile = new Profile();
        BeanUtils.populate(profile,map);
        recordimpl recordimpl = new recordimpl(new pecordimpl());
        Boolean addrecord = recordimpl.Addrecord(profile);
        if(addrecord){
            return  "forward:selectAll?method=selectAll";
        }else {
            return  "redirect:"+request.getContextPath()+"Addrecord?method=addrecord";
        }


    }

}
